package hk.com.fgoproduction.getdroplets.Lib.Common.ToolInstance

import android.util.Log

/***
 * Static class(object) for log
 */
object LogInstance {

    /***
     * Usage: This is used to generate log by providing channel choices and flag for printing log or not
     *
     * @param Tag
     * - Tag of Log
     *
     * @param Text
     * - Text body of Log
     *
     * @param Channel
     * - Log channel, for details
     * @see LogType
     *
     * @param showLog
     * - Flag for printing log or not
     *
     * @throws Exception
     * - will be thrown if wrong channel is chosen
     */
    fun log(Tag: String, Text: String, Channel: LogType, showLog: Boolean = false) {
        if (showLog) {
            when (Channel) {
                LogType.DEBUG -> Log.d(Tag, Text)
                LogType.VERBOSE -> Log.v(Tag, Text)
                LogType.ERROR -> Log.e(Tag, Text)
                LogType.WARN -> Log.w(Tag, Text)
                LogType.INFO -> Log.i(Tag, Text)
                else -> throw Exception("Wrong Channel")
            }
        } else {
            //throw Exception("Log not shown. Check 4th value passed.")
        }
    }

    /***
     * Usage: Enum class for channel type
     *
     * Member:
     * - DEBUG(d)
     * - ERROR(e)
     * - INFO(i)
     * - WARN(w)
     * - VERBOSE(v)
     */
    enum class LogType {
        DEBUG, ERROR, INFO, WARN, VERBOSE;
    }
}
